package com.example.guava;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnel;
import com.google.common.hash.Funnels;

import java.util.UUID;

public class BloomFilterTest {
    private static long maxCount = 1000000000L;
    private static long testCount = 100000000;
    private final static BloomFilter bloomFilter = BloomFilter.create(Funnels.longFunnel(),maxCount);
    public static void main(String[] args) {
        for (long i = 0; i < testCount; i++) {
            bloomFilter.put(UUID.randomUUID().hashCode() & 0x0000FFFFFFFFFFFFL);
        }
        for (long i = 0; i < testCount/10; i++) {
            System.out.println(i + "是否命中"+ bloomFilter.mightContain(UUID.randomUUID().hashCode() & 0x0000FFFFFFFFFFFFL));
        }
    }
}
